package com.sanhe.roller.fragment;

import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.sanhe.roller.R;
import com.sanhe.roller.databinding.FragmentFatBinding;

public class FatFragment extends BaseWorkFragment {

    private static final String TAG = "FatFragment";
    FragmentFatBinding binding;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        binding = FragmentFatBinding.inflate(inflater, container, false);

        binding.modeLayout.cover.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                return true;
            }
        });
        binding.modeLayout.cw.setOnClickListener(v ->  activeCW());
        binding.modeLayout.pulse.setOnClickListener(v -> activePulse());
        binding.timeLayout.time.setText("45");
        return binding.getRoot();
    }


    private void activeCW() {
        binding.modeLayout.cw.setTextColor(Color.WHITE);
        binding.modeLayout.cw.setBackgroundResource(R.mipmap.mode_text_bg_press);
        binding.modeLayout.pulse.setTextColor(getResources().getColor(R.color.mode_text));
        binding.modeLayout.pulse.setBackgroundResource(R.mipmap.mode_text_bg);

        binding.modeLayout.pulseView.setBackgroundResource(R.mipmap.mode_bg);
        binding.modeLayout.pulseView.setAlpha(0.5F);
        binding.modeLayout.wave.setImageResource(R.mipmap.wave);
        binding.modeLayout.cover.setVisibility(View.VISIBLE);


    }

    private void activePulse() {
        binding.modeLayout.cw.setTextColor(getResources().getColor(R.color.mode_text));
        binding.modeLayout.cw.setBackgroundResource(R.mipmap.mode_text_bg);
        binding.modeLayout.pulse.setTextColor(Color.WHITE);
        binding.modeLayout.pulse.setBackgroundResource(R.mipmap.mode_text_bg_press);

        binding.modeLayout.pulseView.setBackgroundResource(R.mipmap.mode_bg_active);
        binding.modeLayout.pulseView.setAlpha(1F);
        binding.modeLayout.wave.setImageResource(R.mipmap.wave_active);
        binding.modeLayout.cover.setVisibility(View.GONE);
    }
}
